home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 1320 / 1320.xpi / chrome / gmanager.jar / content / overlayToolbarClick.js < prev    next >
Text File  |  2010-01-22  |  2KB  |  65 lines

  1. // Gmail Manager
  2. // By Todd Long <longfocus@gmail.com>
  3. // http://www.longfocus.com/firefox/gmanager/
  4.  
  5. var gmanager_ToolbarClick = new function()
  6. {
  7.   this.click = function(aEvent)
  8.   {
  9.     var toolbarPanel = aEvent.target;
  10.     
  11.     if (aEvent.button != 2)
  12.     {
  13.       var account = toolbarPanel.displayAccount;
  14.       
  15.       if (account)
  16.       {
  17.         var manager = Components.classes["@longfocus.com/gmanager/manager;1"].getService(Components.interfaces.gmIManager);
  18.         var action = null;
  19.         
  20.         switch (aEvent.button)
  21.         {
  22.           case 0: // Left Click
  23.             action = manager.global.getCharPref("toolbar-left-click");
  24.             break;
  25.           case 1: // Middle Click
  26.             action = manager.global.getCharPref("toolbar-middle-click");
  27.             break;
  28.           default:
  29.             break;
  30.         }
  31.         
  32.         switch (action)
  33.         {
  34.           case "check-messages":
  35.             account.loggedIn ? account.check() : account.login(null);
  36.             break;
  37.           case "compose-message":
  38.             action = manager.global.getCharPref("compose-tab-location");
  39.             gmanager_Accounts.loadCompose(account.email, action, null);
  40.             break;
  41.           case "blank":
  42.           case "current":
  43.           case "existing":
  44.           case "focused":
  45.           case "background":
  46.           case "window":
  47.           {
  48.             // Check if the account is logged in and the reset unread count preference
  49.             if (account.loggedIn && manager.global.getBoolPref("toolbar-reset-unread-count"))
  50.               account.resetUnread();
  51.             
  52.             gmanager_Accounts.loadInbox(account.email, action);
  53.             break;
  54.           }
  55.           default:
  56.             break;
  57.         }
  58.       }
  59.       else
  60.         window.openDialog("chrome://gmanager/content/login/login.xul", "login", "centerscreen,chrome,modal");
  61.     }
  62.     
  63.     return true;
  64.   }
  65. }